<?php
/**
 * <https://y.st./>
 * Copyright © 2017 Alex Yst <mailto:copyright@y.st>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org./licenses/>.
**/

$xhtml = array(
	'title' => 'Learning Journal',
	'subtitle' => 'CS 1102: Programming 1',
	'copyright year' => '2017',
	'body' => <<<END
<h2 id="Unit1">Unit 1</h2>
<p>
	I&apos;ve anxiously awaited the availability of the coursework.
	At 22:05 (in my time zone), I was finally able to begin.
	I started by taking a look at the learning journal, programming assignment, and discussion for the week.
	It looks like the learning journal assignments in this course are going to be the same as they were in <a href="https://y.st./en/coursework/CS1101/" title="Programming Fundamentals">CS 1101</a>: a detailed overview of my activities for the week and a reflection.
	Like last time, this&apos;ll be really easy; I already keep a <a href="https://y.st./en/weblog/">daily journal</a> of everything I do, so completing this kind of learning journal assignment simply means writing it all down here instead of there.
</p>
<p>
	The programming assignment had me worried.
	It said to first install NetBeans.
	I&apos;m always weary when specific software is needed.
	I only run free software, and this NetBeans might be something proprietary.
	Thankfully, it&apos;s not; <a href="https://netbeans.org/cddl-gplv2.html">it&apos;s covered by the $a[GNU] $a[GPLv2]</a>, a common free software license.
	Strangely, NetBeans <a href="https://packages.debian.org/search?keywords=netbeans">isn&apos;t in the latest stable version of Debian</a>, Debian 8, but <strong>*was*</strong> present in Debian 7 and <strong>*is*</strong> present in the testing version of Debian that will become Debian 9 one day.
	Not having NetBeans in my repository made it more difficult to install.
	I downloaded and ran the installer, but it couldn&apos;t find my OpenJDK installation for some reason.
	I wasn&apos;t sure what to do about that, and I thought I&apos;d need to use my own development environment (Geany plus the command line).
</p>
<p>
	The discussion assignment was about four operators, ones that are very familiar from $a[PHP].
	This is a course on Java though, not $a[PHP], so I waited until reading the course material for the week to write up my discussion assignment submission, just in case a couple of them do something different in Java.
</p>
<p>
	The introduction to the reading material had this to say:
</p>
<blockquote>
	<p>
		This course has no prerequisites, although a general familiarity with computers would certainly be helpful.
	</p>
</blockquote>
<p>
	Lies!
	<span title="Programming Fundamentals">CS 1101</span> was a prerequisite to this course.
	On that same page, the first page that contains study material, it also says this:
</p>
<blockquote>
	<p>
		In unit 1 we learned about compilers and interpreters and their role to check syntax of a program, however, some errors can actually be identified by the IDE editor before the program is subjected to either the compiler or interpreter.
	</p>
</blockquote>
<p>
	Um.
	This <strong>*is*</strong> <a href="https://y.st./en/coursework/CS1102/#Unit1">Unit 1</a>, and we haven&apos;t even mentioned compilers or interpreters yet.
	I know what both are, but what is this page even talking about?
	I get the feeling this course will be a bit disorganised, not unlike the assignment instructions from <span title="Programming Fundamentals">CC 1101</span>.
	Later in the unit, we did discuss interpreters and compilers, but that was only after passing through this introduction that said we&apos;d already covered them.
</p>
<p>
	The instructions in the introduction to the reading assignment direct us to the Windows download page for NetBeans.
	You can&apos;t assume everyone&apos;s running Windows, because we&apos;re not.
	Only most of us are.
	I located the download I need, though I didn&apos;t seem to be able to get the software working for the time being.
	Later in the week, I decided to try again to install NetBeans.
	This time, I had a breakthrough.
	I did some research online to find where my $a[JDK] installation was, so I could manually tell NetBeans where to find it.
	After pointing the NetBeans installer int the right direction, it finally gave me a more helpful error message.
	Previously, it told me it couldn&apos;t find $a[JDK].
	Now, it told me that $a[JRE] was present, but a full $a[JDK] was needed.
	I use OpenJDK as my Java environment.
	You&apos;d think that something with &quot;JDK&quot; in the name would contain a $a[JDK] implementation.
	However, that&apos;s not exactly the case, at least in the Debian package of it.
	Either the OpenJDK team or the Debian Project team broke OpenJDK up into different components, and I intuitively had the OpenJDK $a[JRE] installed, but not the OpenJDK $a[JDK].
	Running <code>sudo aptitude install <a href="apt:openjdk-7-jdk">openjdk-7-jdk</a></code> on the command line fixed the main problem with the NetBeans installer, though the installer kind of stumbled a bit.
	It no longer complained that no $a[JDK] was installed, but after the installation was running, it complained that no $a[JDK] was found in the location that the installer had decided it was.
	I aborted the installation, deleted the work it&apos;d completed, and ran it again.
	This time, I tried a few different directories until I found the one the installer wanted the $a[JDK] path set to.
	Everything seemed to work this time.
</p>
<p>
	The reading assignment was as follows:
</p>
<ul>
	<li>
		<a href="https://docs.oracle.com./javase/tutorial/getStarted/">Trail: Getting Started (The Java™ Tutorials)</a>
	</li>
	<li>
		<a href="https://docs.oracle.com./javase/tutorial/getStarted/cupojava/netbeans.html">&quot;Hello World!&quot; for the NetBeans IDE (The Java™ Tutorials &gt; Getting Started &gt; The &quot;Hello World!&quot; Application)</a>
	</li>
	<li>
		<a href="https://docs.oracle.com./javase/tutorial/java/concepts/">Lesson: Object-Oriented Programming Concepts (The Java™ Tutorials &gt; Learning the Java Language)</a>
	</li>
	<li>
		<a href="https://docs.oracle.com./javase/tutorial/java/nutsandbolts/">Lesson: Language Basics (The Java™ Tutorials &gt; Learning the Java Language)</a>
	</li>
	<li>
		<a href="https://en.wikipedia.org./wiki/ASCII">ASCII - Wikipedia</a>
	</li>
	<li>
		<a href="https://netbeans.org./kb/docs/java/javase-intro.html">Developing General Java Applications - NetBeans IDE Tutorial</a>
	</li>
	<li>
		<a href="https://netbeans.org./kb/docs/java/quickstart.html">NetBeans IDE Java Quick Start Tutorial</a>
	</li>
	<li>
		<a href="https://netbeans.org./kb/trails/java-se.html">General Java Development Learning Trail - NetBeans Tutorials, Guides and Articles</a>
	</li>
	<li>
		<a href="https://ocw.mit.edu./courses/electrical-engineering-and-computer-science/6-092-introduction-to-programming-in-java-january-iap-2010/lecture-notes/MIT6_092IAP10_lec01.pdf">6.092 Lecture 1: Types, Variables, Operators - MIT6_092IAP10_lec01.pdf</a>
	</li>
	<li>
		<a href="https://www.youtube.com./watch?v=0iXc1Me2xiA">CS1102 Programming 1 Unit 1 Lecture 2 - YouTube</a>
	</li>
	<li>
		<a href="https://www.youtube.com./watch?v=T6Sa3U7OT_o">CS1102 Programming 1 Unit 1 Lecture 3 - YouTube</a>
	</li>
	<li>
		<a href="https://www.youtube.com./watch?v=_e65BDDjY9Y">CS1102 Programming 1 Unit 1 Lecture 1 - YouTube</a>
	</li>
	<li>
		<a href="http://gwydir.demon.co.uk./jo/numbers/binary/intro.htm">Introduction to Binary</a>
	</li>
	<li>
		<a href="http://linfo.org/ascii.html">ASCII definition by The Linux Information Project (LINFO)</a>
	</li>
	<li>
		<a href="http://math.hws.edu./javanotes/c1/index.html">Javanotes 7.0, Chapter 1 -- Overview: The Mental Landscape</a>
	</li>
	<li>
		<a href="http://math.hws.edu./javanotes/c2/index.html">Javanotes 7.0, Chapter 2 -- Programming in the Small I: Names and Things</a>
	</li>
</ul>
<p>
	I found it interesting that the video lecture called $a[PHP] a shell script language.
	I myself use $a[PHP] as a shell script language on a daily basis.
	However, most people don&apos;t look at $a[PHP] as a shell script language.
	Instead, they think $a[PHP] is Web-specific and only runs in the context of a Web server, sending pages to a Web browser upon request.
	$a[PHP] actually does have full shell script capabilities though, and can even be used to develop graphical applications (though I haven&apos;t use it for that myself yet).
	It was a pleasant change to hear my native language not written off as &quot;just a website thing&quot;.
</p>
<p>
	The lecturer also addressed that if you&apos;re watching the video on a mobile telephone, that device is nothing more than a mobile computer.
	Yes!
	I&apos;ve been trying to tell people for years that smartphones aren&apos;t telephones at all, but computers.
	Many people write me off though.
	Arguably, some mobile telephones actually are telephones, but those devices aren&apos;t the ones that are Web-enabled or in any way able to engage in video playback.
	People sometimes think I&apos;m silly for calling my mobile a &quot;mobile&quot; or a &quot;device&quot;, but it&apos;s a simple matter of accuracy.
	It&apos;s not a telephone, so I don&apos;t call it a &quot;phone&quot;.
	A real telephone has no need for a $a[CPU] or operating system.
</p>
<p>
	I found the explanation of the Java Virtual Machine to be very enlightening.
	I already knew how it worked, but the lecturer showed me a new way to think about it.
	I&apos;ve always considered &quot;compiled&quot; java code to be be a middle state between actual compiled code and source code.
	The Java language is both compiled and interpreted, as it must be compiled first, then the compiled code must be interpreted.
	It&apos;s a strange hybrid of the two systems.
	It&apos;s useful, but still very strange.
	The lecturer talked about how the $a[JVM] is an emulator though.
	It emulates a system that has never really existed.
	It&apos;s an abstraction.
	The Java compiled compiles code to run on this nonexistent system, then the code is run on the emulator that emulates this system.
	I still think my original notion is more accurate, as emulation is an expensive process.
	Java is known to be inefficient, but if it were doing full emulation, it&apos;d have a lot more overhead.
	Instead, Java probably functions more like $a[Wine], but instead of acting as a compatibility $a[API] for Windows-based instructions, acts as a compatibility $a[API] for this idealised Java computer.
</p>
<p>
	The lecturer says NetBeans is a lot easier to install, get set up, and update than Eclipse.
	That was a laugh!
	That totally depends on your local setup.
	I could install Eclipse as easily as running <code>sudo aptitude install <a href="apt:eclipse">eclipse</a></code>.
	I&apos;ve done that before, and Eclipse is still in the Debian 8 repositories.
	To update it, all I&apos;d have to do is run <code>sudo aptitude upgrade</code>, and Eclipse would be updated along with the rest of my software.
	It wouldn&apos;t need to be updated individually.
	With NetBeans, if I want to update it, I need to delete the current installation from my file manager, find and download the new version, then run the installer and hope it works.
	I&apos;ll likely need to locate the $a[JDK] path again too to make the installation successful.
	As for the initial install, it took me four days to figure out how to get it to install properly.
	NetBeans was <strong>*not*</strong> easier to install!
	Which $a[IDE] is easier to install, set up, and keep updated is platform-dependant.
	The lecturer also said that installing NetBeans automatically installs the $a[JDK] as well, but again, that&apos;s platform dependant.
	It doesn&apos;t do that on Debian unless installed through $a[APT] or Aptitude, which isn&apos;t an option on Debian 8.
</p>
<p>
	I got a lot of error messages when running the initial code provided to us.
	One was this:
</p>
<blockquote>
	WARNING torsocks[10829]: [syscall] Unsupported syscall number 229. Denying the call (in tsocks_syscall() at syscall.c:165)
</blockquote>
<p>
	The other twelve error messages were this:
</p>
<blockquote>
	WARNING torsocks[10829]: [syscall] Unsupported syscall number 186. Denying the call (in tsocks_syscall() at syscall.c:165)
</blockquote>
<p>
	Is ... Is NetBeans trying to access the Internet in some way while executing my code?
	It really shouldn&apos;t be doing that, there&apos;s nothing network-related about the initial code.
	I located NetBeans&apos; proxy settings so I could set those directly and quit using <code>torsocks</code>, and that cleared up the issue.
</p>
<p>
	When explaining data types, the lecturer said that using a byte, we can store one of 2^8 different numbers, then calculates that as two-hundred fifty-five different numbers.
	As usual, people are forgetting to count zero.
	There are two-hundred fifty-<strong>*six*</strong> possibilities, and 2^8 is equal to 256.
	Additionally, the lecturer said the values go from -127 to +128.
	If Java is like other programming languages, that&apos;s backwards.
	The <strong>*negative*</strong> limit is further from zero than the positive limit.
	They should&apos;ve said the range is from -128 to +127.
</p>
<p>
	The introduction to object-oriented concepts was pretty much just review.
	I use object-oriented programming concepts in $a[PHP] all the time.
	$a[PHP]&apos;s sort of a hybrid language, able to be used in a functional way or an object-oriented way.
	I tend to prefer the object-oriented way of expressing code when there&apos;s even the slightest bit of complexity involved.
	As soon as data has to fit some domain or there&apos;s two or more functions that are interrelated, I set up a class with a validating constructor and/or turn the functions into class methods.
	The parts on variables and control flow were also just review, though the part on operators was helpful for making sure my understanding of $a[PHP] operators also applied to Java.
	Different languages use different operators.
	For example, $a[PHP], Python, and Java all use <code>!=</code> to perform an inequality test.
	However, Lua instead uses the <code>~=</code> operator for that purpose.
</p>
<p>
	The material on $a[ASCII] was review as well, and these days, $a[ASCII] itself shouldn&apos;t really used much.
	Unicode has superseded it.
	$a[ASCII] is unfortunately embedded in many networking protocols, but I have hope this&apos;ll be corrected in the future.
	That said, maybe it won&apos;t.
	Take the use of $a[DNS] in other protocols, for example.
	$a[DNS] can store names of just about any value, but in practice, it only holds names with characters from a subset of $a[ASCII].
	The reason for this is that other characters aren&apos;t permitted by other protocols, such as $a[HTTP].
	Did the standards bodies decide to fix this limitation in $a[HTTP]?
	No.
	Instead, they built a hacky workaround and called it <a href="https://en.wikipedia.org./wiki/Internationalized_domain_name">$a[IDN]s</a>.
	Instead of actually fixing the problem, they made a bit of a mess of it.
	It&apos;s highly probable that other such hacky workarounds will be put in place to make use of $a[ASCII] in various networking protocols work globally instead of actually repairing the outdated protocols themselves.
	The $a[ASCII] <strong>*table*</strong> still remains useful though even outside $a[ASCII]&apos;s archaic use, as the beginning of the greater Unicode table and the section of Unicode most used by certain groups of people.
	It&apos;s be an incredible waste of time and brain space to try to memorise the $a[ASCII] table, but there&apos;s some things I think everyone working in computer science should remember about the character order.
	Control characters come first, at the beginning of the $a[ASCII] table.
	After that, come digits, upper-case letters, and lower-case letters, in that order. Between these four groups, and after the lower-case letters, other characters are stored.
	When in doubt as to the order of non-alphanumeric characters, just consult an $a[ASCII] table; they&apos;re not hard to find.
	I use an application on my computer frequently to find characters I can&apos;t type from the Unicode table, and it has an option to display just the $a[ASCII] section, which also comes in handy for sorting.
	For example, I have my <a href="https://bandcamp.com/y_st">Bandcamp collection</a> organised in Unicode order.
	Albums beginning with digits are near the beginning, while albums from artists that can&apos;t even be bothered to capitalize the proper nouns that are their album titles are at the end.
	Bandcamp doesn&apos;t offer automated sorting options, so I have to do all that manually using their drag-and-drop album-sorting interface.
	When album titles start with strange characters, the $a[ASCII] table&apos;s nice to have around to help get everything set up right.
</p>
<p>
	The part on binary was review as well.
	Binary&apos;s just like the number system we commonly use, except that binary&apos;s in base two and the one we usually use in in base base ten.
	All the regular concepts apply though.
	I wouldn&apos;t say all number systems are this similar, though.
	For example, there&apos;s also Roman numerals and such, that don&apos;t really have the same concept of a base that binary and our common number system do.
	ally marks are another great example.
	Binary has a lot in common with our common number system that people take for granted, things that really aren&apos;t just a given.
</p>
<p>
	Before getting to work on my programming assignment, I looked through NetBean&apos;s settings a bit.
	First, I made the whitespace visible.
	As a programmer, there&apos;s no excuse for having any character be invisible.
	Ever.
	Last term, I was in a class in which we used $a[IDLE].
	One of $a[IDLE]s main flaws was that there wasn&apos;t a way to get it to display whitespace, but NetBeans doesn&apos;t suffer from this problem.
	Next, I noticed a comments section in the template NetBeans provided me to start with:
</p>
<blockquote>
<pre><code>/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */</code></pre>
</blockquote>
<p>
	NetBeans has license headers?
	Neat.
	I tried changing the license header though, and it had no effect.
	I tried deleting the project and starting fresh.
	That didn&apos;t do it either.
	Eventually, I figured out I needed to change the license header, delete the initial class file, then recreate the initial class file.
	The license header is <strong>*only*</strong> added when the file is first created.
	Changes made later are <strong>*not*</strong> applied.
	I&apos;m not yet sure how to set a default license header though.
	It&apos;d save me a lot of time if I could just have the license header always start as specifying all my projects as being covered by the $a[GNU] {$a['GPLv3+']}.
	As I started work on the assignment, I noticed NetBeans was automatically indenting code I added, but it was doing so using spaces instead of tabs.
	That had to be corrected before I could get anywhere.
	Otherwise, I&apos;d have to go back and reformat my code manually before submitting it.
	Additionally, NetBeans had hijacked my tab key, so instead of inserting tab characters, it inserted strings of spaces.
	I had that same problem with $a[IDLE] last term.
	Why is it that all the $a[IDE]s I end up assigned do this by default?
	If I wanted to insert spaces, I&apos;d hit the space bar repeatedly.
	Instead, I hit the tab key because I want <strong>*tabs*</strong>.
	I disabled the &quot;Expand Tabs to Spaces&quot; option, but that gave the tab key an incredibly bizarre behaviour.
	It inserted four spaces the first time you hit it, then turned the spaces into a tab the next time, then added four more spaces the next time, and so on.
	Next, I set the &quot;Number of Spaces to Indent&quot; option to zero.
	That ... kind of did what I wanted.
	The tab key no longer added spaces anywhere, but it would always indent to exactly the indention level the $a[IDE] assumed I&apos;d want.
	Actually, it was pretty neat, aside from the fact I couldn&apos;t override it.
	Hitting the tab key again wouldn&apos;t do anything at all.
	I could only indent to exactly where the $a[IDE] thought I should.
	In most cases, the $a[IDE] will probably get it right, but there should always be a way for the programmer to type what they actually want as well, even when the $a[IDE] doesn&apos;t agree.
	My next try got it right.
	I set the space indention level to the same number as the tab width, and the tab key indented using tabs first to the level the $a[IDE] thought I wanted, then added further tabs when hit again.
</p>
<p>
	The first thing I noticed when working on the actual code is that I needed to square a number.
	I did some research, and found Java lacks an operator for this.
	My native language, $a[PHP], also lacks such an operator, but I just came from a course on Python, which does have an exponentiation operator.
	In any case, exponentiation can be performed with a function or simply emulated with basic multiplication.
	The multiplication option seems cleaner when working with small exponents, so I did that.
	The <a href="https://y.st./en/coursework/CS1102/GravityCalculator.java.xhtml">assignment</a> was easy enough to complete in a single sitting without testing until complete, but I&apos;m not sure how to verify my answer.
	The code compiles and runs without error, but is the <strong>*semantics*</strong> of the code correct?
	It should be.
	It looks correct.
	The template NetBeans started me with had a couple mentions of the author of the code, which it set to my log in name, instead of the name I have set in my computer.
	I ended up correcting them to my preferred name, but since my preferred name isn&apos;t my birth name and University of the People knows my by my birth name for now (until I get it legally changed), other students won&apos;t recognise it.
	The coursework submission remains anonymous.
</p>
<p>
	I didn&apos;t do as well on the ungraded quiz as I&apos;d like to have, but this week&apos;s not really turned out as planned, so it&apos;s not too surprising.
	Apparently, my terminology&apos;s a bit rusty, so I should&apos;ve paid more attention to the reading assignment.
</p>
<p>
	The discussion board assignment this week didn&apos;t really present a complex enough subject facilitate meaningful interaction.
	Instead, we just covered the use of four Java operators that given the operator, the meaning of it was intuitive (if you&apos;ve worked with other programming languages, anyway).
	There wasn&apos;t really anything for me to say about what other students posted, as we all basically said the same thing.
	Instead, I took the opportunity to introduce terminology to students that didn&apos;t seem to have heard the word &quot;modulo&quot; before.
	Thankfully, most students seemed to know about modulo division, but there were a few that talked about the goofy concept of a &quot;remainder&quot; from regular division.
	In division though, we don&apos;t have a remainder.
	We&apos;re not bound to just numbers that are integers, so there&apos;s no need for a &quot;remainder&quot;.
</p>
<p>
	I used to know Java.
	I took a course on it at another university, but Java has certain problems that I really don&apos;t like.
	The most obvious is a feature called &quot;overloading&quot;.
	Multiple methods can all share a name, as long as they don&apos;t share a signature.
	That is, if the name is identical, but parameters the method takes must be different.
	Personally, I think giving the same name to multiple methods is a very bad idea.
	However, it gets worse.
	When you accidentally pass the wrong variables into a method call or your variables don&apos;t have the types you thought they did, it causes <strong>*misleading*</strong> error messages to be thrown by the compiler.
	Instead of telling you you used bad values as arguments, the compiler complains that you called an undeclared method.
	For me, this makes me focus my bug search in the wrong places.
	I look for reasons why the method might not be defined by that point in the code yet.
	I look for typos in the method name, both in the method declaration and the method call.
	I check everything related to the method, and nothing related to the arguments, as the arguments weren&apos;t said to be the problem.
	After the course ended, I promptly dropped the Java language and never looked at it again.
	I don&apos;t remember how to write even basic Java applications.
	Now though, I&apos;d like to get into mobile application development.
	I&apos;m not sure I want to do it as a job or anything, but there&apos;s applications I lack on my Replicant device, and I&apos;d like to be able to program what I need.
	That means figuring out how to use Java, as Replicant is an Android distribution and Android applications are developed in Java.
	In this course, I&apos;m hoping to relearn Java, and this time, actually use it.
	As for the overloading issues ...
	If I can remember that a &quot;missing method&quot; error usually has nothing to do with the method name and everything to do with bad arguments, I might actually be able to get somewhere.
</p>
<h3>Discussion post drafts</h3>
<blockquote>
	<p>
		The increment operator, <code>++</code>, simply increments the value stored in the variable it&apos;s used with by one.
		If the variable once held the value <code>2</code>, it&apos;ll now hold the value <code>3</code>.
		The variable can be placed to the left or to the right of the increment operator (<code>variable++</code> or <code>++variable</code>), but if the expression is a subexpression of a greater expression, order matters.
		This subexpression will return the value of the variable before or after the incrimination, respectively.
	</p>
	<p>
		The <code>&amp;&amp;</code> operator checks to see if two subexpressions are both true.
		If both ate true, the whole expression will be true, but if one or both are false, the expression will be false.
	</p>
	<p>
		The <code>!=</code> operator checks to see if two subexpressions are not equal to one another.
		If they&apos;re equal, the whole expression will be false, but the expression will be true otherwise.
	</p>
	<p>
		The <code>%=</code> operator performs modulo division using the value of the variable on the left as the first operand, and the subexpression on the right as the second.
		The result of this modulo division is then assigns the resulting value back to the variable on the left.
	</p>
</blockquote>
<blockquote>
	<p>
		The word &quot;remainder&quot; is kind of misleading.
		In real division, there is no remainder; you divide even that which doesn&apos;t divide evenly.
		For example, five divided by two isn&apos;t &quot;two remainder one&quot;; it&apos;s two and a half or two point five.
		What the <code>%</code> and <code>%=</code> operators do is perform modulo division, an operation that removes the evenly-divisible part and leaves the rest.
		It&apos;s like moving around something; it&apos;s like an analogue clock.
		If it&apos;s 3:00 and you move forward twenty-five hours, it&apos;s not 28:00.
		Instead, you perform modulo division on your result to get the real result.
		twenty-eight modulo twenty-four (or twelve, if you&apos;re on a twelve-hour clock) is four, so it&apos;s now 4:00.
	</p>
</blockquote>
<blockquote>
	<p>
		If there&apos;s a remainder, it implies you haven&apos;t actually used mathematical division.
		Mathematically, we have fractions and decimals.
		We don&apos;t need to neglect to divide the whole number.
		Five divided by two isn&apos;t &quot;two remainder one&quot;, it&apos;s two and a half or two point five.
		It&apos;s very rare that we&apos;d need to know what &quot;can&apos;t&quot; be divided.
		Instead, the <code>%</code> and <code>%=</code> operators are often used when we need to &quot;wrap around&quot; back to the beginning.
		For example $a[ROT13] is a weak encryption scheme that moves each of the 52 English letters forward by one space, but moves uppercase letters and lowercase letters separately.
		It&apos;s a variation of the Caesar Cipher.
		Each letter is part of a set of twenty-six, and is basically assigned a number. &quot;A&quot; is zero, &quot;Z&quot; is twenty-five, and the other uppercase letters fall between.
		$a[ROT13] moves each one forward by thirteen places.
		So what happens when you need to encode the letter &quot;S&quot;?
		The number for &quot;S&quot; is eighteen, so adding thirteen gives us thirty-one.
		There is no letter for number thirty-one, so what do we do?
		We have to wrap around, and that&apos;s what modulo division does.
		thirty-one modulo twenty-six is five, so $a[ROT13] encodes &quot;S&quot; as &quot;F&quot;.
	</p>
</blockquote>
<blockquote>
	<p>
		Integers aren&apos;t the only numbers we have, so when we divide, there is no remainder.
		Five divided by two isn&apos;t &quot;two remainder one&quot;, it&apos;s just two and a half or two point five.
		If we want to know what part doesn&apos;t divide evenly, it&apos;s not a &quot;remainder&quot; we&apos;re after.
		Instead, we&apos;re just looking for the solution to a modulo division problem; and that&apos;s what the <code>%</code> and <code>%=</code> operator are for.
		While five divided by two is two point five, five <strong>*modulo*</strong> two is one, which is the answer we were looking for.
		This also makes things easier to express.
		Mathematically, two point five is expressed as <code>2.5</code>.
		But how is &quot;two remainder one&quot; expressed?
		Even if we had a way to express it, when we actually needed that &quot;remainder&quot; alone (when programming), we&apos;d need to find a way to parse it out of the whole answer.
		Additionally, the solution to a mathematical expression can always be dropped into another equation.
		For example, in <code>4 * (5/2)</code>, we divide five by two first.
		If five divided by two is two point five, the whole expression evaluates to ten.
		But what if five divided by two is &quot;two remainder one&quot;?
		How do we multiply &quot;two remainder one&quot; by four?
	</p>
</blockquote>
<h2 id="Unit2">Unit 2</h2>
<p>
	The <a href="https://y.st./en/coursework/CS1102/SnakeEyesCount.java.xhtml">assignment</a> for the week said to use an <code>if</code> statement from within a loop, but a <code>do</code> <code>while</code> statement was a cleaner way to accomplish the goal.
	The test was built right into the loop, so no <code>break</code> statement was needed.
	That could go well for me, leaving me with cleaner code, or it could backfire on me, causing me to lose points on the assignment.
	I can&apos;t see the grading criteria until it&apos;s too late.
	I didn&apos;t get started on the assignment as soon as I should have, but thankfully, my code all came together with little hassle.
	I did hit a snag when I nested my initial code within the 1000-time run loop, but I just needed to move the division calculation to the end of the code, outside both loops.
	On the first run of the thousand-time version, the code output a perfect <code>36</code>, the exact average you&apos;d expect.
	It didn&apos;t do that every time though, and once I added the code to convert the number to a float before dividing, the number was no longer perfect, but it still gets pretty close to the statistical average.
</p>
<p>
	I didn&apos;t have the level of focus I normally have for my coursework.
	One interaction in the forum showed me I don&apos;t understand enums like I thought I did.
	This shows me an area I need to study again.
	I also read feedback from our professor on my learning journal submission from last week.
	I&apos;ve tried to keep this entry more brief than last week, as requested.
</p>
<p>
	My main attitude right now is one of lethargy.
	I&apos;m not sure what my problem is this term, but both this week and last week, I&apos;ve had issues with focus.
	I need to figure out where my enthusiasm went and get it back.
	I should&apos;ve had this week&apos;s work done pretty quickly, but instead, I put it off until the last minute.
	That needs to stop.
</p>
<p>
	I suppose the main thing I relearned this week is how to properly terminate a statement.
	I keep leaving off the semicolons.
	In $a[PHP], my native language, we also use semicolons to terminate our statements, but I haven&apos;t had time to build anything in $a[PHP] lately.
	Last term, I worked in Python for my coursework though, and statements there are terminated by ... line feeds.
	I&apos;ve also been programming Minetest mods lately, and those are written in Lua.
	Lua also just uses line feeds to terminate statements.
	Python and Lua have made me soft.
	I&apos;ve also learned I need to study better.
	I need to go back and review enums.
</p>
<p>
	My final thought for the week is that I&apos;m confused by this <code>TextIO.java</code> file the assignment mentioned.
	It didn&apos;t seem to be necessary for the assignment, and was only mentioned as a hint, so I was able to move on without it.
	The <a href="https://y.st./en/coursework/CS1102/#Unit3">Unit 3</a> assignment mentions it as well, though this time, it includes the link to get it.
	I&apos;m hoping it wasn&apos;t actually necessary for the Unit 2 assignment though, as we didn&apos;t have access to that file yet.
</p>
<h3>Discussion post drafts</h3>
<blockquote>
	<p>
		A for loop loops over its code block until a counter-based conditional tells it to stop.
		This results is the code executing a predetermined number of times.
		A for loop might look something like this:
	</p>
	<blockquote>
<pre><code>for(int i=0; i&lt;32; i++) {
	int square = i*i;
	System.out.println(&quot;Squaring &quot; + i + &quot; gives us &quot; + square + &quot;.&quot;);
}</code></pre>
	</blockquote>
	<p>
		It&apos;s worth noting though that all three statements in the for loop header are optional.
		<code>for(;;)</code> is perfectly valid.
		The counter could be initialised outside the header before the loop begins and the counter could be incremented within the loop.
		However, if you leave out the test condition, you&apos;ve got no counter at all and the loop will continue until broken with a <code>break</code> statement or something similar.
	</p>
	<p>
		A for-each loop instead uses iteration.
		It executes its code block once for each item in the given enum, usually doing something with each item in the enum supplied.
		An enum is basically a data type for storing multiple values.
		In $a[PHP], this is comparable to an array, and in Python, this is comparable to a dictionary, tuple, or list.
		&quot;Enum&quot; is short for &quot;enumerable&quot;, and enums can be enumerated with a for-each loop.
		Like with a for loop, the for-each loop will execute an expected number of times based on the number of items in the enum; once for each item.
		If we know how many elements are in the enum, we know how many times the block will be executed.
		A for-each loop might look like this:
	</p>
	<blockquote>
<pre><code>String[] fruitlist = {&quot;apple&quot;, &quot;banana&quot;, &quot;cherry&quot;, &quot;date&quot;, &quot;elderberry&quot;}

for(String fruit : fruitlist) {
	System.out.println(fruit);
}</code></pre>
	</blockquote>
	<p>
		Some languages, such as $a[PHP], use a different key word for for loops and for-each loops.
		In $a[PHP], a for-each loop uses the <code>foreach</code> and <code>endforeach</code> key words, while a for loop uses the <code>for</code> and <code>endfor</code> key words for for loops.
		Java is not like this.
		In Java, the <code>for</code> key word is used for both types of loops, and the loop type is determined not exclusively by the key word chosen, but also by the structure of the loop&apos;s header.
	</p>
</blockquote>
<blockquote>
	<p>
		You make a great point.
		Java enums don&apos;t use keys/value pairs.
		I suppose my comparison to constructs in other languages was confusing.
		My point had been that like these constructs from other languages, enums contain multiple values.
	</p>
	<p>
		The planetary example on <a href="https://docs.oracle.com./javase/tutorial/java/javaOO/enum.html">this page</a> makes it look like there&apos;s a way to store key/value pairs in an enum, though I&apos;m a bit confused as to how it works.
		It&apos;s highly likely I&apos;m misinterpreting the example.
	</p>
</blockquote>
<blockquote>
	<p>
		You mention that a for loop can only be used when the index is required or the array needs to be modified.
		How is that?
		In your example, there was no array, so there were no indeces and no array elements to modify.
	</p>
	<p>
		Great explanation of enums!
		I didn&apos;t quite understand them as well as I should have from the readings.
	</p>
</blockquote>
<blockquote>
	<p>
		You make a good point that the incrimination expression can either increment or decrement.
		It can also do neither, and the loop can rely on an expression within the loop to do that instead.
	</p>
	<p>
		However, a for each loop isn&apos;t always executed at least once.
		That would be a do while loop.
		A for each loop will be executed zero times if given an array of zero items.
	</p>
</blockquote>
<blockquote>
	<p>
		You&apos;re right, the for each loop is more restrictive.
		It serves a very specialised purpose, looping through all elements of an array, so that&apos;s all it can do.
		A for loop is more generic, more generalised.
		Because of that, it has more power, but also more complexity.
	</p>
</blockquote>
<h2 id="Unit3">Unit 3</h2>
<p>
	The <a href="https://y.st./en/coursework/CS1102/Unit3.java.xhtml">programming assignment</a> this week was easy enough, but we were required to use that strange <code>TextIO.java</code> file to read the text file we were given.
	As a result, we didn&apos;t actually learn how to read and parse a file ourselves in Java.
	For that reason, I&apos;m not sure what we actually accomplished, and that disappoints me a bit.
	The comments of the <code>TextIO.java</code> file say that the class doesn&apos;t do things the correct or efficient way, so it&apos;s not even like we were supposed to read that file to learn how file-reading should be achieved.
</p>
<p>
	That said, I&apos;m not sure about the other students, but I did learn a couple smaller things.
	First, I learned about the <code>equals()</code> method of the <code>String</code> class.
	It seems like such a small detail, but it&apos;ll be hugely invaluable in any program that needs to check for certain strings or compare strings, both of which are common use cases.
	Second, I skipped a typecast I felt was redundant and found something interesting. I tried to perform some maths involving <code>100.0</code>, then stick it in a <code>float</code>-type variable.
	That didn&apos;t work out so well.
	I figured that <code>100.0</code> was a <code>float</code>, so a mathematical expression involving it would also be a <code>float</code>.
	I started with a faulty premise though, so I ended up with a faulty conclusion.
	By default, decimal numbers aren&apos;t actually stored as <code>float</code>s, they&apos;re stored as more-precise <code>double</code>s!
	I considered adding in a typecast, but instead just switched the variable&apos;s type to match the expression&apos;s.
	More precision doesn&apos;t hurt, right?
</p>
<p>
	One of the most helpful interactions this week for me helped me understand why a <code>try</code> block requires a <code>catch</code> or <code>finally</code> block to be valid.
	I would think that sometimes you just want to catch exceptions to avoid program-crashing, but logically, you still need a <code>catch</code> block for that.
	Any exception of a class not specifically caught by a <code>catch</code> block causes a program halt.
	A <code>try</code> block without a <code>catch</code> block wouldn&apos;t surpress all exceptions; it&apos;d fail to have anything to catch!
	Instead, an empty <code>catch</code> block would need to be added to the end of the <code>try</code> block, one specified to catch exceptions of the <code>Exception</code> class, the class all other exception classes descend from.
	Of course, in most cases, you don&apos;t want the <code>catch</code> block to be empty, you want it to actually do domething.
	However, the <strong>*theory*</strong> of an empty <code>catch</code> block can be used to understand why a <code>catch</code> block would even be necessary if empty.
</p>
<h3>Discussion post drafts</h3>
<blockquote>
	<p>
		A try ... catch statement is a way to tell the program to brace itself for potential errors, as well as tell it what to do if those errors occur.
		Normally, an exception (what most object-oriented languages such as Java throw instead of raising &quot;errors&quot;) will halt the execution of the program.
		An exception leave the program in a place it doesn&apos;t understand, unable to continue.
		By bracing itself to expect these errors, it&apos;s ready to handle them with the instructions you&apos;ve provided for doing so.
	</p>
	<p>
		A try ... catch statement might look something like this:
	</p>
	<blockquote>
<pre><code>double dub;
try {
	dub = 3.0 / previously_defined_int;
} catch(Exception e) {
	System.out.println(&quot;An error occurred. previously_defined_int was probably set to zero, and we can&apos;t divide by that.&quot;);
	dub = 0;
}</code></pre>
	</blockquote>
	<p>
		In this case, we try to divide by an integer defined elsewhere in the program.
		The integer might be zero though, which it doesn&apos;t make sense to divide by because of some multiplication strangeness surrounding the number.
		We don&apos;t know for sure that the number is or is not zero when we write the code though, so we hope for the best, but prepare for the worst in case it doesn&apos;t work out.
		After catching the exception, we can output an error message (or not) and set our variables that would&apos;ve been set had we succeeded.
		By setting our variables, we can limit the damage of failure, as later code that needed those variables will still have them.
	</p>
</blockquote>
<blockquote>
	<p>
		Yeah, you&apos;re right, I should&apos;ve covered the fact that exceptions can be caught based on which class they belong to.
		In my example, I used the superclass that all exception classes descend from, which would catch all exceptions.
		That&apos;s not the only way to do it though.
		Multiple <code>catch</code> blocks could be specified, and each one could catch a different class of exception.
		Like you said, if done that way, any exception belonging to a class without a corresponding <code>catch</code> block will crash the program.
		One way to get around that if you wanted multiple <code>catch</code> blocks but didn&apos;t want the chance of unexpected exceptions crashing the program would be to write out your normal <code>catch</code> blocks, but then add one more <code>catch</code> block at the end that catches anything in the <code>Exception</code> class.
	</p>
</blockquote>
<blockquote>
	<p>
		When something exceptional and bad has happened is a great way to explain when exceptions should be thrown.
		Exceptions can be caught to prevent the execution of your program from terminating, but you don&apos;t even always want to do that.
		In many of my projects, an unexpected situation means I&apos;ve done something wrong as the programmer, as these projects don&apos;t take in any outside data.
		In these types of programs, I throw exceptions when my program&apos;s in a state I assume it&apos;ll never be in.
		That way, when I run it, it&apos;ll crash and give me a stack trace.
		If it&apos;s in an unexpected place, I don&apos;t <strong>*want*</strong> it to finish what it&apos;s doing; I want it to exit immediately and tell me what went wrong.
		In other cases, I write a program that <strong>*does*</strong> take in outside data.
		In those cases, I like to throw exceptions when my code runs into a situation it doesn&apos;t understand.
		That way, I can add the necessary logic for handling that type of data, as I&apos;ll know what to add.
		For example, I built a Web spider, and it would find hyperlinks on a page and try loading the pages from those hyperlinks to try to find more hyperlinks.
		In two different occasions, I ran into problems with the $a[URI] handler, and both times, purposely crashing the program helped me debug.
		In the first instance, it turned out the $a[URI] parser I was using was buggy.
		It couldn&apos;t handle $a[URI] references that contained only a fragment component if that fragment component contained a colon.
		It wasn&apos;t mine and I couldn&apos;t find a way to make it work properly, so I built my own to replace it.
		Without thrown exceptions though, I&apos;d&apos;ve just ended up with bad data in my database instead of even knowing there was an issue.
		In the second case, it turned out some Web author didn&apos;t know $a[XHTML]/$a[HTML].
		They used a phrase instead of a $a[URI] as the target of their hyperlink.
		My spider was ending up with nonsense data because of that, so I reworked the spider to log any invalid &quot;$a[URI]s&quot; for manual review later (so I could check for false negatives) and had it avoid passing that bad data to the part of the code that would load the next page.
		Again, exceptions and stack traces were very helpful to the process, and in both cases, something exceptional and bad <strong>*had*</strong> occurred.
	</p>
</blockquote>
<blockquote>
	<p>
		It&apos;s worth noting that a <code>catch</code> block doesn&apos;t <strong>*have*</strong> to print out anything in regards to the exception.
		Often times, I don&apos;t use <code>try</code>/<code>catch</code> blocks because my goal in throwing exceptions is to <strong>*cause*</strong> the program to halt.
		When I use <code>try</code>/<code>catch</code> blocks, it&apos;s because I&apos;m expecting known problems that I can&apos;t solve.
		For example, I would use <code>try</code>/<code>catch</code> blocks when processing user data.
		Users can never be trusted, so I expect them to input erroneous data sometimes.
		If processing a large amount of input files, I don&apos;t want all the errors popping up, so I silently catch the exceptions that might get thrown, and maybe log them in some way.
		I don&apos;t output any information about the exception to anything visible to the user though.
		In some cases, you <strong>*do*</strong> want to output error messages and move on, but the outputting of error messages isn&apos;t a requirement.
	</p>
</blockquote>
<blockquote>
	<p>
		I hadn&apos;t thought about it before, but it makes sense that a <code>try</code> block requires a <code>catch</code> block or <code>finally</code> block.
		A <code>catch</code> block has the possibility of getting the program back on track after an exception has been thrown.
		Even without a <code>catch</code> block though, a <code>try</code> block can have purpose when combined with a <code>finally</code> block.
		The <code>finally</code> block can perform necessary cleanup tasks before the program finishes aborting.
		But what would a <code>try</code> block do without either of these two other block types?
		It wouldn&apos;t be any different semantically than just having that same code without the block, so it&apos;s not allowed.
	</p>
</blockquote>
<h2 id="Unit4">Unit 4</h2>
	<p>
		While I was writing up my initial discussion post for this course, I ran into another idiocy in Java.
		This time, it&apos;s not in Java itself, but in the terminology that surrounds it.
		We all know what parameters and arguments are in regards to functions and methods, right?
		Well, Java mixes it up a bit just to be confusing.
		What everyone else calls a &quot;parameter&quot;, Java calls a &quot;formal parameter&quot; (or &quot;dummy parameter&quot;).
		Meanwhile, what everyone else calls an &quot;argument&quot;, Java calls an &quot;actual parameter&quot; (or &quot;argument&quot;, like everyone else).
		In other words, Java needlessly makes the word &quot;parameter&quot; ambiguous.
		In order to be clear about what you mean, the word &quot;parameter&quot; can never be used alone.
		It must always be qualified with the word &quot;formal&quot;, &quot;dummy&quot;, or &quot;actual&quot;.
		Additionally, Java redefines the word &quot;function&quot;.
		As far as I can tell, the definition of the word &quot;method&quot; in Java is the same as in other languages.
		However, other languages define a &quot;function&quot; as being a method that&apos;s not bound to an object class.
		Java instead redefines it as a method with a return value.
		Why isn&apos;t Java using the same, standard terminology as everyone else?
		I can&apos;t see a single good reason for Java having redefined standard programming terminology like this.
	</p>
	<p>
		One thing I learned this week is how single quotes and double quotes in Java are used.
		In some programming languages, they&apos;re used interchangeably.
		This is the case in Python.
		In other languages, they behave differently, but both delimit strings.
		This is the case in $a[PHP].
		However, Java has more data types.
		To delimit strings, double quotes are used, and to delimit characters, single quotes are used.
		I also relearned what static method calls are.
		I should know that already, as I deal with the same construct when I use $a[PHP], which I do on a daily basis.
		However, when I was drafting my programming assignment this week, I ran into an error involving the static calling of methods, and instead of jumping right to the obvious fix, I tried a bunch of things that made zero sense to even try.
		While Java does redefine several key pieces of programming terminology, static method calls aren&apos;t one of them.
		I should&apos;ve known exactly what the problem was based on the error message without any guessing.
	</p>
	<p>
		My main interaction this week was probably the one in which a student said I probably should&apos;ve provided example code to go with my explanation.
		I should probably do this in general with all my posts in programming courses.
		Many programming concepts are very familiar to me because I&apos;ve been using them for years, so I forget that other people might need an example to clear up what is meant when I explain these simple concepts, such as those of (formal) parameters and arguments.
		I also got something out of the grading this week.
		Two out of three of the assignments I graded didn&apos;t just assume the required database file they required existed.
		They accounted for the possibility that it wouldn&apos;t, providing an error message and aborting if that was the case.
		Honestly, why <strong>*didn&apos;t*</strong> I do this?
		That&apos;s one of those bare minimum things you do when dealing with user input, such as this file.
		You don&apos;t assume the data exists, you don&apos;t assume the data is valid, and you don&apos;t assume the data is safe.
		In the case of last week&apos;s assignment, invalid/&quot;unsafe&quot; data simply results in a bad count.
		No arbitrary executions should happen.
		However, the threat of the file being missing is still very real and needs to be dealt with.
	</p>
<h3>Discussion post drafts</h3>
<blockquote>
	<p>
		Parameters are basically local variable names within a method that don&apos;t have any value associated with them until the method is called.
		When a method is called with arguments, the values of the arguments are assigned to the names given by the parameters.
		In this way, a method call can influence some of the internal aspects of the method.
		The readings suggest that parameters don&apos;t just apply to methods though.
		They may be present in any type of subroutine definition.
		I&apos;m not yet sure what subroutines besides methods exist in Java yet.
		Arguments are values without names that will be passed into a subroutine and assigned to the names given by the parameters to form full local variables with name and value that can be used within the subroutine.
		That allows us to define the subroutine to make use of those local variables by name without knowing when we define the method what the values passed in will be yet.
		It&apos;s worth elaborating too what I mean when I say the value passed in has no name.
		You can use an expression in the method call, and that expression might simply be a named variable.
		The value just doesn&apos;t have a name within the method until passed as an argument, but in may or may not have a name outside the method.
	</p>
	<p>
		The concept of &quot;formal parameters&quot; and &quot;actual parameters&quot; is a strange one.
		In most languages, the word &quot;parameter&quot; refers to the name declared in the function/method definition, and that&apos;s the way I used the word in the preceding paragraph.
		However, in Java, these are referred to as either &quot;formal parameters&quot; or &quot;dummy parameters&quot;.
		In Java, the arguments I mentioned in the above paragraph are called either &quot;arguments&quot; (as I called them) or &quot;actual parameters&quot;.
		That is to say, when speaking about method definitions and calls in Java, the word &quot;parameters&quot; is ambiguous.
		If you&apos;re coming from having worked with other programming languages, this is a bit frustrating and counter-intuitive.
	</p>
	<p>
		Eck, D. J. (2016, December). Javanotes 7.0, Chapter 4 -- Programming in the Large I: Subroutines. Retrieved from <a href="http://math.hws.edu./javanotes/c4/"><code>http://math.hws.edu./javanotes/c4/</code></a>
	</p>
</blockquote>
<blockquote>
	<p>
		Yeah, I probably should&apos;ve included an example.
		I also should&apos;ve mentioned that (formal) parameters include a type declaration.
		If an argument of the wrong type is passed into the method, Java will look for a different method.
		The readings this week said that two methods can&apos;t share a name, but in Java, that&apos;s annoyingly false.
		My least favourite thing about the Java language is that two methods <strong>*can*</strong> have the same name, provided the number of arguments or the types of the arguments they take are different.
		The reason I hate this feature so much is that it makes debugging a huge pain in the neck.
		The Java compiler will complain that you are attempting to call undefined methods, so you try to find typos in the method name in the method definition and the method call, but there&apos;s nothing wrong there.
		Instead, the real problem is that you passed bad <strong>*arguments*</strong>; arguments of the wrong type.
		This could be because you passed the wrong variable as an argument or it could be that you you thought the variable you passed was of a different type than it really was.
		An $a[IDE] makes finding the real source of the problem much easier, but honestly, if you need an $a[IDE] to get the job done instead of just basic syntax highlighting, your language is being difficult.
		To be clear, I&apos;m not saying use of $a[IDE]s is bad, just that use of $a[IDE]s should provide an extra layer of ease, not the basic level needed to get anything done efficiently at all; $a[IDE]s should be optional, not for all practical purposes necessary.
	</p>
	<p>
		As an example of (formal) parameters, arguments, and methods with the same name, see this class:
	</p>
	<blockquote>
<pre><code>/*
 * Copyright (C) 2017 Alex Yst
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see &lt;http://www.gnu.org/licenses/&gt;.
 */
package cs1102;

/**
 *
 * @author Alex Yst
 */
public class Unit4 {
	public static void test(int parameter) {
		System.out.println(&quot;The integer version of this method was called.&quot;);
	}
	public static void test(String parameter) {
		System.out.println(&quot;The string version of this method was called.&quot;);
	}
	public static void main(String[] arguments) {
		System.out.println(&quot;This will call the integer version of the method.&quot;);
		test(-7);
		System.out.println(&quot;This will call the string version of the method.&quot;);
		test(&quot;This is a string.&quot;);
	}
}</code></pre>
	</blockquote>
	<p>
		In this example, we see that each method defines the types of the arguments it takes.
		The names assigned to these arguments, as well as the declared types, are the (formal) parameters.
		The values used in the method calls are the parameters.
		Additionally, we see two methods both named <code>test()</code>.
		Java allows this, but only if both (or all, if more than two share a name) take different argument types and/or a different number of arguments.
	</p>
</blockquote>
<blockquote>
	<p>
		I like how you explained that.
		I completely agree.
		(Formal) Parameters are like variable names and type declarations.
		Parameters are just the values assigned to those variable names.
		That&apos;s why within the method, we can use them just like any other local variable: they <strong>*are*</strong> just local variables within the method.
		Anything you can do with a variable, you can do within the function with the (formal) parameter.
		You can even assign it a new value!
	</p>
</blockquote>
<blockquote>
	<p>
		Code reuse through defined methods is a very powerful tool.
		For starters, it allows us to be a bit less verbose in our code.
		We don&apos;t have to copy and paste the same thing in multiple places.
		Even better, when we update the code, we can update it only in the method, instead of in several places, as we didn&apos;t just paste the code everywhere we needed it.
		Code reuse is made easier in other projects, too.
		Our class can be included in another program, and that program can pass the values it needs to into our methods.
		It allows us to build more general software to fill a larger set of needs.
	</p>
</blockquote>
<blockquote>
	<p>
		I guess (formal) parameters can be thought of as placeholders.
		Any variable can, really.
		Instead of directly using the value we intend to, we assign it to a variable, then use the variable in our computations.
		The same applies to (formal) parameters and arguments.
		The (formal) parameter declares the type and name of the variable to be used locally within the method.
		When the method&apos;s called, but argument assigns a value to the (formal) parameter; that is to say, it assigns a value to the local variable defined by the (formal) parameter in the method definition.
	</p>
</blockquote>
<h2 id="Unit5">Unit 5</h2>
<p>
	I read over the two programming assignments this week before getting started on the reading assignment.
	I was very confused at first.
	One programming assignment asks us to write a <code>main()</code> method that defines a particular class, then instantiate that class.
	A method ... that defines the class?
	I thought the assignment was misworded, as I seem to recall few programming assignments in another course, <a href="https://y.st./en/coursework/CS1101/" title="Programming Fundamentals">CS 1101</a>, being worded in ways that made no sense at all.
	I had make guesses as to what was actually required sometimes.
	Obviously, this assignment was one like those.
	I needed to do one of two things and I wasn&apos;t sure which.
	One option was to define the class as specified, then add a <code>main()</code> to it that causes it to instantiate itself and call its own methods.
	This option seemed the most convoluted in a way, but also seemed to better fir the directions.
	The second option was to not define the class in the same file even; just include and use it the way we included and used the <code>TextIO</code> class in a <a href="https://y.st./en/coursework/CS1102/Unit3.java.xhtml">previous assignment</a>.
	I was wrong though.
	The assignment made perfect sense if you know how Java actually works.
	In $a[PHP], you can define classes from within the methods of other classes.
	However, Java&apos;s a bit strange in that you can&apos;t even have code that runs outside a method.
	Everything you program in Java is a class definitions, essentially.
	As such, I expected class definitions to be required to be more ... I don&apos;t know, grounded.
	As in, they had to be defined in the outermost scope.
	Additionally, I though Java had a one-class-per-file rule, though perhaps that&apos;s just convention.
	In any case, I learned that classes in Java can in fact be defined from within methods of other classes.
	The assignment makes perfect sense.
</p>
<p>
	Another thing I learned was how to set up a constructor method.
	The constructor method is simply a method sharing its name with its class.
	This method should return no value.
	Maybe $a[PHP] got this convention from Java!
	In the past, $a[PHP] also used constructor methods named after the class they instantiate, though this was later replaced with the <code>__construct()</code> method.
	Java&apos;s option to give multiple methods the same exact name as long as they take different arguments is a major pain in my neck when debugging.
	In most use cases, I see this feature as providing zero useful value and only causing problems.
	However, constructor methods are the only exception to this.
	When passing different argument types to a method, you might as well use a different method name for clarity, especially when using variables to pass the values.
	However, when constructing an object, you may want to be able to do so in a variety of ways.
	Having multiple constructor methods makes this possible.
</p>
<p>
	I guess my main interaction this week was when someone said that I was right that understanding the difference between a class and an object is difficult.
	I never said that though!
	Understanding the difference between a class and an object is as easy as understanding the difference between the integer <code>-3</code> and the data type <code>int</code>.
	Honestly, you shouldn&apos;t be mixing those two up.
	Would you try to solve an equation that looked like <code>int + 5 * int</code>?
	No, because the data type isn&apos;t a valid value.
	The same is true of objects and classes.
	You don&apos;t perform operations on a class, as a class is only a group, a data type.
	Objects are your actual data.
</p>
<p>
	My final thought for the week is about the second programming assignment for the week, the multi-week project.
	The project submission form only allowed the upload of four files, but there were five classes to upload:
</p>
<ul>
	<li>
		<code>Employee</code>
	</li>
	<li>
		<code>FullTime</code>
	</li>
	<li>
		<code>PartTime</code>
	</li>
	<li>
		<code>PayrollSystem</code>
	</li>
	<li>
		<code>Vehicle</code>
	</li>
</ul>
<p>
	I left out the <code>PayrollSystem</code> because of the upload limit, which hopefully won&apos;t be a problem.
</p>
<h3>Discussion post drafts</h3>
<blockquote>
	<p>
		A class is a blueprint with which objects can be built.
		The class defines the methods and properties that will be available to the objects created with it.
		In this way, a class is almost like a type definition, allowing you to define new data types in Java.
	</p>
	<p>
		An object is a value created from a class.
		All objects belong to a particular class, and the class determines what the object can and cannot do.
	</p>
	<p>
		A method is a bit harder to explain in Java terminology because Java redefines the standard programming terms.
		Normally, I&apos;d say it&apos;s a function bound to an object class, but Java redefines the word &quot;function&quot;, making that definition incorrect.
		I think the best way to describe it would be that it&apos;s a named subroutine that is bound to a particular object class.
		If the method is static, it can be called directly without an object.
		However, if the method isn&apos;t static, an object of that class must be created and the method called using that object.
	</p>
	<p>
		Attributes are sort of like subvalues within an object.
		The attribute name acts as a key, forming a key/value pair with the attribute value.
		The class defines what properties (both by name and by type) an object will have, but the values of the properties can differ between objects of the same class.
	</p>
	<p>
		Finally, we come to instantiation.
		Instantiation is the process of creating an instance of a class; this instance is what we call an object.
		In Java (and many other languages), 
	</p>
	<p>
		The discussion assignment says to discuss a practical example of these Java concepts from experience, but I don&apos;t have practical experience in Java.
		The only things I&apos;ve written in Java were for assignments in this course and for another course at another school.
		All of these concepts apply to $a[PHP] though, and I do have practical experience in that, so I&apos;ll discuss how I used them there.
	</p>
	<p>
		I was writing a Web crawler and ran into an issue with the built-in $a[URI] parser of the language.
		Under certain circumstances, the built-in subroutine&apos;d fail, and as my spider expected reasonable data, it&apos;d throw an exception and crash when it instead got absolutely no data at all returned from the subroutine.
		At first, I build a suite of subroutines for processing $a[URI]s as strings and as arrays of strings, as well as subroutines for converting between the two forms.
		I soon realised though that because $a[URI]s have their own grammar and syntax, they&apos;re basically a specialised data type ans should be treated as such.
		I lumped the subroutines into a single class and reworked them to be object methods.
	</p>
	<p>
		This class is called <code>\\st\\y\\uri</code>, though had it been written in Java, It&apos;ve been called <code>st.y.URI</code>.
		Whenever I need to process a $a[URI], I instantiate a new object from this class.
		The constructor method takes a $a[URI] string as an argument, parses it, and sets the appropriate private attributes.
		In the process, it normalises the $a[URI] components and insures they&apos;re valid.
		If invalid data isused in the constructor, an exception is thrown.
		Getters are used to read any properties needed, while setters normalise their input before setting the properties.
		Additionally, again, invalid input into the setters will cause exceptions to be thrown.
		For storage of $a[URI]s, a method is provided to convert these $a[URI] objects back into a (now-normalised) string, and child classes can define other processing methods as needed, depending on the subtype of $a[URI] being processed.
		I now treat $a[URI]s as their own data type and this data type behaves as you&apos;d think it should.
	</p>
	<p>
		I&apos;ve also been know to extend built-in classes to provide more intuitive constructors and/or more methods for more-specific use cases.
		One of the great things about object-oriented programming is that you can reuse the functionality of an existing class as a base for adding functionality to when defining your own class.
		You don&apos;t need to rewrite existing functionality to add it to a new class.
		Additionally, objects of the child class are considered to be both of the child class (mainly) and of the parent class.
		That makes objects of your new extended classes drop-in replacements for objects of the parent class!
		In Java, like in $a[PHP], multiple inheritance isn&apos;t an option though.
		Because classes cant inherit from two or more parent classes, a child class can&apos;t be used to create objects that&apos;ll act as drop-in replacements for objects of multiple other classes (unless all those classes are part of the same inheritance chain) and if you need to combine the functionality of multiple classes, your new class will need to re-implement the methods of all but one of the classes you need your class to imitate.
	</p>
</blockquote>
<blockquote>
	<p>
		It&apos;s not actually all that difficult to understand the differences between classes and objects.
		A class is like a variable type.
		An object is an instance of that type.
		For example, <code>5</code> would be like an instance of a hypothetical <code>int</code> class.
		The object is the value.
		<code>int example = int + int;</code> wouldn&apos;t make any sense.
		Instead, you need the instances of <code>int</code> for the right side of the expression: <code>int example = 3 + 5;</code>.
	</p>
</blockquote>
<blockquote>
	<p>
		I wouldn&apos;t say there&apos;s no point in defining a class without instantiating any objects from it.
		That statement may be true for some languages, but not others.
		In my native language, $a[PHP], a class definition can be used to make functions and constants autoloadable.
		They can also be used to create new variable name spaces.
		These aren&apos;t uses I actually make use of, but they could be useful to some programmers.
		As for Java, Java won&apos;t run without a class.
		For a Java program to function, a class must be defined with a static <code>main()</code> method.
		No class means no execution.
	</p>
</blockquote>
<blockquote>
	<p>
		It&apos;s true that there&apos;s a difference between objects and non-object values, but at the same time, their example is useful.
		Objects share many qualities with non-object values.
		<code>int</code> in their example is very much like a class of non-object values, and <code>9</code> is like an instance of it.
		Or to put it better, a class is like a value type and an object is like a value of that type.
	</p>
</blockquote>
<blockquote>
	<p>
		I like how you bring up that a class should focus on one particular type of task.
		While a class could be designed to tackle the entire problem solved by the program, it&apos;s a messy way to build your code.
		If each class focuses on a single type of task, the code will be easier to build, easier to test, easier to read, and easier to understand.
		Focus each class on a single task and have the class perform that task well.
	</p>
</blockquote>
<blockquote>
	<p>
		I don&apos;t think the purpose of a static variable is to increase memory efficiency.
		It&apos;s true that this results in the value only being stored in one place in memory, but even with an unlimited amount of memory, this would be useful in the same situations as now.
		Specifically, a static variable allows all instances of the class to share the same value.
		If one object changes the value, all other objects of the same class know about the change immediately.
		It might not be possible to check the variable space and find all instances of the class, just to find out if one object changed the value, then update all other objects to match.
		When the value needs to be recorded independently of all instances and shared between instances, that&apos;s when a static variable comes in handy.
	</p>
</blockquote>
<h2 id="Unit6">Unit 6</h2>
<p>
	My main interactions of the week were probably through grading assignments.
	Two of the three students I graded for wrote up their assignment submissions for last week not to use a static set of numbers, but to take user input.
	That was awesome, and I wish I&apos;d done the same.
	However, their implementation could use some work.
	Both students used the number zero as a terminator.
	The user could input as many numbers as they liked, as long as none of the numbers were zero, then enter a zero to indicate that the full set had been input.
	What if a user needed to add a zero or zeros to their set?
	These programs wouldn&apos;t allow it.
	The third student instead defined an array of the numbers we were told to use for the assignment, then looped through them, providing a more concise solution than mine, though with the same static result.
	What I especially liked about this solution wasn&apos;t its conciseness; I&apos;d considered the same idea myself and decided against it.
	Instead, what I liked was how it used the loop not only to add the numbers to the <code>StatsCalc</code> object, but also to output the numbers visually.
	I hard-coded each number in two places; one that displayed the set of numbers and one to add the numbers to the object.
	If I wanted to update my code, I&apos;d need to remember to do so in two places.
	This student&apos;s code removed that problem, and only had the numbers hard-coded in one spot without any loss of output.
</p>
<p>
	I continued the multi-week programming assignment.
	I wanted to add helpful comments, but the code doesn&apos;t even do anything yet.
	I know how the classes operate, but not how they&apos;re actually used.
	I&apos;ll have to wait until next week to know what comments to add.
	Again though, the assignment submission form didn&apos;t allow me to upload the whole project.
	The upload limit was cut in half from last week too, so I was only able to upload two classes.
	I chose <code>FullTime</code> and <code>PartTime</code>.
	As before though, I included all five classes using $a[XHTML] in the text area of the form, so hopefully that won&apos;t be a problem.
</p>
<p>
	The main assignment for the week was a mess.
	We were to define a <code>getVolume()</code> method that returns no value, but outputs the width, height, depth, weight, and volume to the output buffer.
	Weight isn&apos;t even related to volume, so it shouldn&apos;t be output by the <code>getVolume()</code> method.
	Plus, because the output is to the buffer instead of being returned by the method, it can&apos;t be used elsewhere in a program.
	Additionally, we were to define a <code>weight</code> property and a <code>calculateWeight()</code> method. This method was to calculate the weight and, again, output it to the buffer instead of returning it.
	Since the weight should only be output once, I ended up calling this method from within <code>getVolume()</code>, making it so <code>getVolume()</code> output the weight by calling <code>calculateWeight()</code>.
	I also had <code>calculateWeight()</code> set the value of the <code>weight</code> property, though this property isn&apos;t actually used by any other method.
	It&apos;s a useless property.
	I originally had my code calculate the volume as well, but then deleted that code and replaced it to a call to the superclass&apos; <code>getVolume()</code>.
	The superclass we were assigned to work with still output the information to the buffer instead of returning it, but at least it output only the volume, truer to the method name.
	Our child class is supposed override that method to output five statistics instead; we redefine what the method is even supposed to output.
	As a practice project for learning concepts, this assignment is just fine.
	However, if we were developing this class for an employer, we should be fired.
	Finally, our <code>main</code> class&apos; <code>main()</code> method is supposed to output the five statistics, but the instructions specifically state to have the <code>getVolume()</code> method of the <code>MatchBox</code> class output that information.
	That means we either output the information twice or we have the <code>main()</code> method output it by calling the <code>getVolume()</code> method.
	The obvious choice is the latter, as it provides cleaner, unduplicated output, but that means our <code>main()</code> method is composed of two lines.
	To kind of show a point, I merged the lines into one, which worked just as well.
	Literally, the only line you need in that method is <code>new MatchBox(5, 10, 3).getVolume();</code>.
	I could&apos;ve provided an option to take user input to decide the dimensions (and perhaps the density) of the box, but I decided the one-liner with explanation comment was a better route.
	I&apos;ve been learning from the code of other students, and I hope they&apos;re learning from me.
	I think this version of my code has more to offer education-wise in exchange.
</p>
<h3>Discussion post drafts</h3>
<blockquote>
	<p>
		Polymorphism is the ability to have multiple classes of objects that meet the type requirements of a single variable type.
		Java is a strongly-typed language, so all variables are of a specific type.
		Each class is a type, so a variable meant to hold an <code>exampleZero</code> object (declared with <code>exampleZero var0;</code>) can&apos;t contain a reference to an object of the <code>exampleOne</code> class.
		At least usually.
		However, with polymorphism, this becomes possible in some situations.
		For example, if the <code>exampleOne</code> class is a child class of the <code>exampleZero</code> class, <code>var0</code> could hold an object of the <code>exampleOne</code> class because objects of that class <strong>*also*</strong> belong to the parent class.
		This is useful in a number of situations.
	</p>
	<p>
		First, we have the case of direct inheritance.
		I&apos;ve written a class called <code>st.y.uri</code>.
		This class parses, normalises, and enforces the syntactic validity of $a[URI]s in accordance with <a href="https://tools.ietf.org/html/rfc3986">$a[RFC] 3986</a>.
		By making the most important methods final, I ensure that this class and all child classes adhere to this standard.
		However, for example, <code>telnet:</code>-scheme $a[URI]s must not only adhere to $a[RFC] 3986, but also <a href="https://tools.ietf.org/html/rfc4248">$a[RFC] 4248</a>.
		If I specifically want to ensure a <code>telnet:</code>-scheme $a[URI] is syntactically valid and normalised, I use one of the child classes: <code>st.y.uri.telnet</code>.
		I still might want to use objects of this child class with a method that requires an <code>st.y.uri</code> instance as an argument though, and because of polymorphism, I can do that.
		(Remember that a (formal) parameter and an argument combine to form what is essentially a local variable.)
		The method signature requests an object of type <code>st.y.uri</code>, but my object of class <code>st.y.uri.telnet</code> is of two types: <code>st.y.uri.telnet</code> and (because it&apos;s a child class of it) <code>st.y.uri</code>.
		Had my class been written in Java (it&apos;s actually written in $a[PHP]), this object would additionally be of a third type, the <code>object</code> type.
	</p>
	<p>
		As a quick example, this code should work fine:
	</p>
	<blockquote>
<pre><code>public class Unit6_parent {
	public void parent_method() {
		System.out.println(&quot;Parent method called.&quot;)
	}
}

public class Unit6_child extends Unit6_parent {
	public void child_method() {
		System.out.println(&quot;Child method called.&quot;)
	}
}

public class Unit6 {
	public static void use_object(Unit6_parent object) {
		object.parent_method();
	}
	public static void main(String[] arguments) {
		Unit6_child object = new Unit6_child();
		use_object(object);
		object.child_method();
	}
}</code></pre>
	</blockquote>
	<p>
		In this example, the <code>use_object()</code> method expects an object of type <code>parent_class</code>.
		When it gets an object of type <code>child_class</code>, that works too, as objects of type <code>child_class</code> <strong>*are*</strong> objects of type <code>parent_class</code>.
		Objects are of multuple types; a type for their own class and a type for each of their ancestor classes (not just their direct parent class).
	</p>
	<p>
		The second important use for this is pretty much the only reason interfaces exist.
		An interface allows you to define the $a[API] your methods will use while not defining the implementation.
		This is more useful for libraries and other code that doesn&apos;t do anything on its own.
		An interface demands that implementing classes implement methods with specific method signatures.
		Objects of classes implementing interfaces then take on the types of the implemented interfaces, in addition to the type of their own class and types of their ancestor classes.
		This allows you to write a method that takes an object of type <code>exampleInterface</code> and call that objects <code>exampleInterfaceMethod()</code> method, provided the <code>exampleInterface</code> interface requires implementing classes to implement that method.
		The object&apos;s implementing class then decides what to actually do with that method.
	</p>
	<p>
		I&apos;m told this is really useful for database extraction, though I&apos;ve never had any luck getting database extraction to work well.
		It&apos;s something I need more practice at, as well as perhaps more education about.
		An interface is useful when you need an object to do something on a high level, but you don&apos;t know or care about the low-level implementation.
		This allows multiple, very different, low-level implementations of the same concept for different use cases.
	</p>
</blockquote>
<blockquote>
	<p>
		There are a lot of differences, but some of those differences are effectively disappearing.
		For example, the newer $a[PHP] versions have the capability to require function/method arguments to have specific types like Java always requires.
		I haven&apos;t gotten to work with that yet, as my $a[PHP] version&apos;s too old, but next time my operating system has a new release (Debian 9!), I&apos;ll have $a[PHP] 7.* at my disposal.
		I&apos;m going to love adding type declarations to all my (formal) parameters.
	</p>
</blockquote>
<blockquote>
	<p>
		Thank you!
		I try to give full acronym names when platforms support it.
		I often run across acronyms I don&apos;t know, so I try not to make other people look up the ones I use.
	</p>
	<p>My sample code <strong>*was*</strong> in Java though.
	That code would never run in $a[PHP].
	</p>
</blockquote>
<blockquote>
	<p>
		Thanks for sharing an example of method overloading with us!
		Overloading is something I struggle with.
		The concept is easy enough to grasp, but having multiple methods with the same name like that makes it difficult for me to debug.
		It&apos;s something I need to work on.
	</p>
</blockquote>
<blockquote>
	<p>
		You mention having multiple constructors as a form of polymorphism.
		I hadn&apos;t thought about it that way, but you&apos;re right.
		Method overloading in Java is having multiple methods of the same class with the same name but with different (formal) parameters.
		Having multiple constructors is an example of this.
		I hadn&apos;t considered it before, but having multiple versions of a method like that would certainly be a form of polymorphism if I&apos;ve ever seen one.
		Thank you for the insight!
	</p>
</blockquote>
<blockquote>
	<p>
		That&apos;s a great real-world example of how one object can be multiple things or fit into multiple categories.
		I tried to explain that in my post, but I don&apos;t think I did it as effectively as you did.
		Your code example was also funny, seeing as you used <code>foo</code> both as being short for &quot;food&quot; and as one of the common example variable names people use.
	</p>
</blockquote>
<h2 id="Unit7">Unit 7</h2>
<p>
	The main programming assignment had an interesting twist to it, if you actually look at how two-dimensional arrays in Java work.
	A two-dimensional array is just an array of arrays, obviously.
	However, we&apos;re using two-dimensional arrays as matrices.
	The arrays in the array aren&apos;t guaranteed to be the same length as one another!
	The assignment asks us to make sure the matrix is square.
	If not, the matrix should be rejected and an error message output.
	We are to use two variables, <code>numberOfRows</code> and <code>numberOfColumns</code>, to compare the dimensions of the matrix.
	This assumes that the matrix is even rectangular though!
	Take for instance this two-dimensional array:
</p>
<blockquote>
<pre><code>int[][] = {
	{0,1,2},
	{3},
	{4,5}
};</code></pre>
</blockquote>
<p>
	If we try to just compare the length with the width, we&apos;d probably check just the width of the first row, as (unless we have a zero by zero matrix, another corner case we should check for), it&apos;ll look like a standard 3*3 matrix!
	No, what we need to do is loop through the first dimension and check the width of each row.
	As we&apos;re supposed to use the <code>numberOfColumns</code> variable, we can set that variable each time we look at the next row, then compare it to <code>numberOfRows</code> before moving to the next row.
	Making sure I was accounting for corner cases was the bulk of the assignment for me.
	The actual computation after being sure we had a valid square matrix was easy.
	The row key and the column key will always intuitively add up to the same number because we&apos;re looking at the secondary diagonal.
	(Had we instead been looking at the first diagonal, the row key and column key would intuitively equal one another instead.)
	All reasonable programming languages properly index from zero, so the two keys combined add up to one less than the array length.
	Just go through the keys of the rows, always subtracting the row key and one from the length to get the column key.
</p>
<p>
	On the other programming assignment, the interface of the application we build doesn&apos;t match the internal terminology.
	For example, we prompt the user for an employee&apos;s bonus, but save it to <code>hourAndHalf</code>.
	Hour and a half is overtime; hours spent on the clock beyond a certain threshold (I believe forty hours per week, here in the States).
	A bonus is extra money for good performance, not at all related to hours worked.
	You can work fewer than the prescribed number of hours and still receive a bonus, if you work hard enough and/or your efforts are appreciated.
	I&apos;m also failing to understand the purpose of this assignment.
	I think this is the final week for this assignment, and all we&apos;ve done is copy code from screenshots.
	We didn&apos;t design anything, nor did we write code based on the designs of someone else.
	We just verbatim copied text from images.
	Personally, I also re-factored the code, making it (in my opinion) better without changing the output.
	However, that wasn&apos;t actually part of the assignment, so it doesn&apos;t really qualify as a purpose of what we did.
	I&apos;m not sure what the deal is, but this week, we&apos;re only allowed to upload three of our five files, according to the submission form.
	I was going to upload <code>Employee</code> and its two subclasses, but this week, I have JavaScript disabled.
	There&apos;s a major bug in the University of the People website, and it causes the site to constantly lock up.
	The only method I&apos;ve found for getting around this is to disable JavaScript in my Web browser.
	I think this is a great example of poor Web design.
	With JavaScript disabled though, it seems the submission form didn&apos;t accept any of my uploaded files, but at least the whole project was accepted in the $a[XHTML]-enabled text area.
</p>
<h3>Discussion post drafts</h3>
<blockquote>
	<p>
		In many languages, such as Python, $a[PHP], and Lua, arrays do not have a fixed size.
		Elements can be added to and removed from the array at will and as needed.
		However, standard Java arrays don&apos;t have this property.
		Instead, they&apos;re of a fixed size, and elements are decided when the array is introduced.
		The value contained in each element can be modified, but new elements cannot be added and old elements cannot be removed.
	</p>
	<p>
		In Java, dynamic arrays fix this problem.
		This type of array doesn&apos;t have a fixed number of elements, so the array can be adjusted at run-time as needed.
		As far as I can tell, there&apos;s no actual data structure in Java that can do this.
		However, Java is a functioning object-oriented language.
		What this means is that we can emulate new data types, such as dynamic arrays, as classes of objects.
		It seems Java even has a built-in class that implements this: <code>ArrayList</code>.
		The advantage of this is obvious: we don&apos;t need to know how many elements we need before we start.
		A fixed-size array must have its size declared right away, and we&apos;ll most likely get the size wrong if we don&apos;t know beforehand what size to use.
		If we make the size too big, we uselessly waste system memory; our program won&apos;t be very efficient.
		If we make the array size too small, we can&apos;t handle all the data; our program won&apos;t be very effective.
		With dynamic arrays, such as those implemented by the <code>ArrayList</code> class, we have perfect-sized data structures at all times.
		As new information is added or old information removed, the <code>ArrayList</code> adjusts to conform to our changing needs.
	</p>
</blockquote>
<blockquote>
	<p>
		In Java, a key word is something such as <code>new</code> or <code>public</code>.
		It&apos;s a language construct build from letters instead of non-alphanumeric characters.
		They&apos;re similar to operators or curly braces, and are built into the language; they don&apos;t exist in packages.
		<code>ArrayList</code> is instead a class, which is why it&apos;s instantiated with the <code>new</code> key word.
	</p>
	<p>
		It&apos;s interesting that the <code>ArrayList</code> class can&apos;t handle primitive data types.
		I wonder why that design decision was made.
	</p>
</blockquote>
<blockquote>
	<p>
		Thanks for the great example!
		I wasn&apos;t sure if you meant that the <code>add()</code> method, when given an index, overwrote the value already at that value or if you meant the value already there got pushed aside to the adjacent index, pushing all later elements forward by one.
		Your example makes it clear that the <code>ArrayList</code> does indeed grow, and the elements are pushed aside as needed.
	</p>
</blockquote>
<blockquote>
	<p>
		That&apos;s a great example of why large arrays are a bad idea in comparison to dynamic arrays, when dynamic arrays are the right tool for the job.
		You mention that it saves memory, and depending on the program, memory might be a scarce resource.
		It&apos;s worth noting though that your user might run your program alongside other applications.
		Memory saving doesn&apos;t just help your program function, it also helps your program play nicely with other software the user might be running at the time your program is run.
	</p>
</blockquote>
<h2 id="Unit8">Unit 8</h2>
<p>
	My main interaction this week was through the grading of assignments.
	No one seemed to figure out how to complete last week&apos;s assignment.
	Everyone got something wrong, and it made me feel bad.
	There was a lot there to over-think, but there wasn&apos;t much to get wrong if you looked at what the assignment asked.
	In fact, the assignment instructions seemed to ask for more than we actually graded on.
	It was possible to get a perfect score without meeting expectations, yet no one did.
</p>
<p>
	It feels like this course was mostly review for me.
	And yet at the same time, it feels like I actually got somewhere this time.
	Last time I took a Java course (outside University of the People), I frequently ran into compilation errors and such.
	I often took way too long to complete assignments, and on the final assignment of the course, I didn&apos;t even have time to perfect my submission.
	I had to hand in code that triggered a compiler warning, but technically did run and meet the requirements.
	That project did meet the professor&apos;s expectations, but it shouldn&apos;t have.
	At a bare minimum, code shouldn&apos;t result in any errors or warnings, but I couldn&apos;t figure out how to restructure the code to remove the warnings.
	Maybe that other course was just poorly-structured, and University of the People&apos;s course is better.
</p>
<h3>Epilogue (Unit 9)</h3>
<p>
	The final exam was longer than I thought it&apos;d be, but not quite as long as the review quiz.
	I didn&apos;t do as well on the review quiz as I&apos;d like to have, but I feel like I did better on the actual final exam.
	I won&apos;t find out for several days how I did though.
</p>
<p>
	My final thought for the term is that I hope <span title="Programming 2">CS 1103</span>, which I&apos;ll be taking next term, gets into either the development of graphical applications or the development of mobile applications.
</p>
<h3>Discussion post drafts</h3>
<blockquote>
	<p>
		According to the reading assignment, each component of a $a[GUI] application can be represented by an object.
		These objects are able to interact with one another via each other&apos;s interfaces.
		The way in which these components interact is called messages.
	</p>
	<p>
		The reading material also says though that in $a[GUI] programming, messages are referred to as events.
		One component will send a message, while another will receive it.
		An event handler is a component that acts as a listener, responding in some way when certain events are triggered.
		Events can be triggered in any number of ways.
		For example, one might be triggered because a certain amount of time has passed or because a user (remote or local) did something.
		Data reception from the network is also an event.
		Responses are a varied lot as well.
		A response may be that a window a user clicked on gains focus.
		Another response might be that a sound is played from the speakers.
	</p>
	<p>
		Listeners have to be registered before they can listen for events.
		This is because the system needs to know to try passing the event to that listener.
		Once registered, the event handler is able to respond to new events as they occur.
		In responding, an event handler may generate a new object that will complete the response, but this isn&apos;t strictly necessary.
		In Java, registered event handlers must implement a specific interface based on what kind of even they&apos;re listening for.
	</p>
</blockquote>
<blockquote>
	<p>
		This has been a long week for me, not because of coursework, but because I&apos;ve been dealing with a health-related problem and some legal stuff, among other things.
		My health issue has cleared up as far as I can tell, and the legal stuff is all but finished, but I was thankful to have a slow week, coursework-wise.
	</p>
	<p>
		If not for that though, I would&apos;ve loved to have been able to try out some stuff.
		Oddly enough, I&apos;ve never built a graphical application in any language, so it would be nice to get a chance to change that!
		It looks like <span title="Programming 2">CS 1103</span> might be a continuation of this course, so maybe we&apos;ll both get a chance to try out graphical programming in Java later.
		I&apos;m not sure about you, but for me, that&apos;ll be next term.
		<span title="Programming 2">CS 1103</span> is a prerequisite to six other required courses, so it seems like a good idea to take it early on.
	</p>
</blockquote>
<blockquote>
	<p>
		I like how you bring up that the change in an object&apos;s state can be an event.
		As most of the program will be made up of objects, that means there&apos;s a lot of places where an event handler could react.
		You also mentioned something I had taken for granted myself.
		If there&apos;s no listeners, nothing reacts to any events that occur.
		It&apos;s a simple concept, but very important to understand.
	</p>
</blockquote>
<blockquote>
	<p>
		You mention that if we can read your post, we&apos;re making use of a $a[GUI]-based application.
		That&apos;s not necessarily true.
		Some Web browsers, such as Lynx, are text-based.
		Using one, we can read your post, as well as most other websites, without any need for a $a[GUI].
	</p>
	<p>
		Your explanation of events, event sources, and event handlers seemed very well thought-out.
	</p>
</blockquote>
<blockquote>
	<p>
		You make a good point about a component only existing as long as the parent does.
		As you said, the <code>JFrame</code> is the root object, which makes it the exception to this.
		However, for example, a button cannot exist once the window it was a part of is removed.
		I also like how you mentioned that events are <strong>*usually*</strong> triggered by the user.
		This isn&apos;t always the case, of course, but the vast majority of events will probably be user-triggered in some way.
	</p>
</blockquote>
END
);
